<template>
  <div>
    <div p-32rpx bg-white>
      <div text-40rpx>充值金额</div>
      <nut-input :input-style="mobileInputStyle" :border="false" py-20rpx v-model="price">
        <template #left>
          <span text-70rpx>￥</span>
        </template>
      </nut-input>
      <submit @click="confirm" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { recharge } from "@/api/member";
import submit from '@/components/sheet-btn/index.vue';
import { money } from '@/utils/RegExp';

const price = ref<number>(0)

const mobileInputStyle = {
  height: "140rpx",
  fontSize: "70rpx"
}
// 点击提交按钮
async function confirm() {
  if (money.test(price.value) && price.value != 0) {
    let res = await recharge({ price: price.value });
    if (res.data.success) {
      uni.navigateTo({
        url: `/pages/mine/payment/payOrder?orderType=RECHARGE&recharge_sn=${res.data.result.rechargeSn}`,
      });
    }
  } else {
    uni.showToast({
      title: '请输入正确的金额',
      icon: 'none'
    })
  }
}
</script>

<style scoped>
</style>
